﻿using System.Data;
using System.Configuration;
using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;
using System.IO;
using System.Data.SqlClient;
using System.Drawing;
using System.Net.Mail;
using System.Text;
using System.Web.Services;


public partial class admin_to_rentupdate : System.Web.UI.Page
{
    int i;
    protected void Page_Load(object sender, EventArgs e)
    {
        Session["edit_id"] = Request.QueryString["id"].ToString();
        Label67.Visible = false;
        Label67.Text = Session["edit_id"].ToString();

        if (Page.IsPostBack == true)
        {
        }
        else
        {

            SqlConnection conn = null;
            conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString);
            conn.Open();

            SqlCommand cmd = new SqlCommand("select * from  properties_rent where p_id='" + Session["edit_id"].ToString() + "'", conn);
            SqlDataReader dr = cmd.ExecuteReader();
            while (dr.Read())
            {
                //DropDownList32.Items.FindByValue(dr[1].ToString()).Selected = true;
                //DropDownList1.Items.FindByValue(dr[2].ToString()).Selected = true;
                DropDownList32.Text = dr[1].ToString();
                DropDownList1.Text = dr[2].ToString();
                TextBox20.Text = dr[3].ToString();


                txtfname1.Text = dr[7].ToString();

                txtlname1.Text = dr[8].ToString();

                TextBox22.Text = dr[9].ToString();
                TextBox21.Text = dr[10].ToString();

                txthno.Text = dr[11].ToString();
                txtcity.Text = dr[12].ToString();
                TextBox3.Text = dr[13].ToString();

                txtssn.Text = dr[14].ToString();

                txtzip.Text = dr[15].ToString();
                TextBox23.Text = dr[16].ToString();
                DropDownList5.Text = dr[17].ToString();
                // DropDownList5.Items.FindByValue(dr[17].ToString()).Selected = true;

                TextBox4.Text = dr[18].ToString();
                DropDownList8.Text = dr[19].ToString();
              //  DropDownList8.Items.FindByValue(dr[19].ToString()).Selected = true;

                TextBox5.Text = dr[20].ToString();

                TextBox35.Text = dr[21].ToString();


                TextBox28.Text = dr[22].ToString();


                txtpfcountry.Text = dr[23].ToString();
                TextBox29.Text = dr[24].ToString();
                TextBox50.Text = dr[25].ToString();

                TextBox13.Text = dr[26].ToString();

                TextBox14.Text = dr[27].ToString();
                txtRoom.Text = dr[28].ToString();

                TextBox25.Text = dr[29].ToString();
                TextBox26.Text = dr[30].ToString();
                DropDownList44.Text = dr[31].ToString();
               // DropDownList44.Items.FindByValue(dr[31].ToString()).Selected = true;
                DropDownList67.Text = dr[58].ToString();
                DropDownList68.Text = dr[60].ToString();


                TextBox15.Text = dr[32].ToString();

                TextBox27.Text = dr[33].ToString();
                //TextBox26.Text = dr[34].ToString();
                TextBox51.Text = dr[35].ToString();

                TextBox27.Text = dr[36].ToString();
                ddlparking.Text = dr[37].ToString();
               // ddlparking.Items.FindByValue(dr[37].ToString()).Selected = true;


                txtpark.Text = dr[38].ToString();
                DropDownList18.Text = dr[39].ToString();
              //  DropDownList18.Items.FindByValue(dr[39].ToString()).Selected = true;

                txtfurniture.Text = dr[40].ToString();
                DropDownList19.Text = dr[41].ToString();
                DropDownList56.Text = dr[124].ToString();
                DropDownList58.Text = dr[126].ToString();
                DropDownList59.Text = dr[128].ToString();
                DropDownList60.Text = dr[130].ToString();

                DropDownList57.Text = dr[132].ToString();
                DropDownList61.Text = dr[134].ToString();
                DropDownList62.Text = dr[136].ToString();
                DropDownList63.Text = dr[157].ToString();


                TextBox57.Text = dr[133].ToString();
                TextBox58.Text = dr[135].ToString();
                TextBox59.Text = dr[137].ToString();
                TextBox60.Text = dr[158].ToString();

               // DropDownList19.Items.FindByValue(dr[41].ToString()).Selected = true;
                txttoilets.Text = dr[42].ToString();
                TextBox53.Text = dr[125].ToString();
                TextBox54.Text = dr[127].ToString();
                TextBox55.Text = dr[129].ToString();
                TextBox56.Text = dr[131].ToString();

                DropDownList20.Text = dr[43].ToString();
              //  DropDownList20.Items.FindByValue(dr[43].ToString()).Selected = true;


                TextBox64.Text = dr[44].ToString();
                ddlkitchen.Text = dr[45].ToString();
              //  ddlkitchen.Items.FindByValue(dr[45].ToString()).Selected = true;



                txtkitchen.Text = dr[46].ToString();
                ddlground.Text = dr[47].ToString();
              //  ddlground.Items.FindByValue(dr[47].ToString()).Selected = true;


                txtground.Text = dr[48].ToString();
                TextBox52.Text = dr[49].ToString();
                DropDownList11.Text = dr[50].ToString();
                //DropDownList11.Items.FindByValue(dr[50].ToString()).Selected = true;

                TextBox8.Text = dr[51].ToString();
                DropDownList16.Text = dr[52].ToString();
               // DropDownList16.Items.FindByValue(dr[52].ToString()).Selected = true;

                txtcpsize.Text = dr[150].ToString();

                TextBox11.Text = dr[53].ToString();
                ddlgarden.Text = dr[54].ToString();
                //ddlgarden.Items.FindByValue(dr[54].ToString()).Selected = true;


                txtgarden.Text = dr[55].ToString();
                DropDownList12.Text = dr[56].ToString();
               // DropDownList12.Items.FindByValue(dr[56].ToString()).Selected = true;


                TextBox7.Text = dr[57].ToString();

                DropDownList15.Text = dr[58].ToString();
                //DropDownList15.Items.FindByValue(dr[58].ToString()).Selected = true;




                TextBox10.Text = dr[59].ToString();
                DropDownList25.Text = dr[60].ToString();
              //  DropDownList25.Items.FindByValue(dr[60].ToString()).Selected = true;




                TextBox17.Text = dr[61].ToString();
                TextBox40.Text = dr[62].ToString();

                txtBasement.Text = dr[63].ToString();
                txtbasetxt.Text = dr[64].ToString();

                txtStrong.Text = dr[65].ToString();

                txtstrongtxt.Text = dr[66].ToString();
                txtAC.Text = dr[67].ToString();

                txtactxt.Text = dr[68].ToString();

                txtBalconies.Text = dr[69].ToString();
                TextBox6.Text = dr[70].ToString();
                DropDownList41.Text = dr[71].ToString();
                txtBalconies1.Text = dr[138].ToString();
                TextBox61.Text = dr[155].ToString();
             //   DropDownList41.Items.FindByValue(dr[71].ToString()).Selected = true;



                txtBalconies0.Text = dr[72].ToString();
                TextBox38.Text = dr[73].ToString();
                DropDownList42.Text = dr[75].ToString();
               // DropDownList42.Items.FindByValue(dr[75].ToString()).Selected = true;




                TextBox9.Text = dr[76].ToString();
                ddlbuiding.Text = dr[77].ToString();
                //ddlbuiding.Items.FindByValue(dr[77].ToString()).Selected = true;




                txtbuilding.Text = dr[78].ToString();
                ddlboiler.Text = dr[79].ToString();
                //ddlboiler.Items.FindByValue(dr[79].ToString()).Selected = true;



                txtboiler.Text = dr[80].ToString();
                ddlanimals.Text = dr[81].ToString();
               // ddlanimals.Items.FindByValue(dr[81].ToString()).Selected = true;


                txtanimals.Text = dr[82].ToString();
                ddlroommates.Text = dr[83].ToString();
              //  ddlroommates.Items.FindByValue(dr[83].ToString()).Selected = true;



                txtroomates.Text = dr[99].ToString();
                TextBox37.Text = dr[85].ToString();
                DropDownList50.Text = dr[86].ToString();
              //  DropDownList50.Items.FindByValue(dr[86].ToString()).Selected = true;




                TextBox19.Text = dr[87].ToString();
                txtProperty.Text = dr[88].ToString();

                txtpsize.Text = dr[89].ToString();
                ddlpsize.Text = dr[90].ToString();
                //ddlpsize.Items.FindByValue(dr[90].ToString()).Selected = true;



                TextBox31.Text = dr[91].ToString();


                TextBox32.Text = dr[92].ToString();
                TextBox33.Text = dr[93].ToString();
                ddlgrnte.Text = dr[94].ToString();
             //   ddlgrnte.Items.FindByValue(dr[94].ToString()).Selected = true;



                txtgrnte.Text = dr[95].ToString();
                ddlvou.Text = dr[96].ToString();

                txtvou.Text = dr[97].ToString();
                ddlsmoke.Text = dr[98].ToString();
                //ddlsmoke.Items.FindByValue(dr[98].ToString()).Selected = true;
                TextBox65.Text = dr[99].ToString();
                txtColor.Text = dr[153].ToString();

                //txtsmoke.Text = dr[99].ToString();


                txtPrice.Text = dr[100].ToString();
                DropDownList33.Text = dr[101].ToString();
               // DropDownList33.Items.FindByValue(dr[101].ToString()).Selected = true;



                txtOldPrice.Text = dr[102].ToString();
                DropDownList51.Text = dr[103].ToString();

                //DropDownList51.Items.FindByValue(dr[103].ToString()).Selected = true;

                // DropDownList51.SelectedValue = dr[103].ToString();
   

                Label68.Text = dr[104].ToString();
                Label69.Text = dr[105].ToString();
                Label70.Text = dr[106].ToString();
                Label71.Text = dr[107].ToString();

                Label72.Text = dr[108].ToString();
                Label73.Text = dr[109].ToString();
                Label74.Text = dr[110].ToString();
                Label75.Text = dr[111].ToString();
                Label76.Text = dr[112].ToString();
                Label77.Text = dr[113].ToString();
                Label78.Text = dr[114].ToString();
                Label79.Text = dr[115].ToString();
                Label80.Text = dr[116].ToString();
                TextBox39.Text = dr[151].ToString();

                TextBox66.Text = dr[141].ToString();
                TextBox67.Text = dr[145].ToString();
                DropDownList64.Text = dr[140].ToString();
                TextBox68.Text = dr[159].ToString();
                txtBalconies2.Text = dr[142].ToString();
                TextBox62.Text = dr[143].ToString();
                DropDownList65.Text = dr[144].ToString();
                TextBox69.Text = dr[160].ToString();
                txtBalconies3.Text = dr[146].ToString();
                TextBox63.Text = dr[147].ToString();
                DropDownList66.Text = dr[148].ToString();
                TextBox70.Text = dr[149].ToString();

////////////////////////////////////////////////////////////////////////////////
                if (TextBox66.Text == "")
                {
                    TextBox66.Visible = false;
              

                }

                else
                {
                    TextBox66.Visible = true;
               
                }

////////////////////////////////////////////////////////////////////////////

                if (DropDownList56.Text == "שדה למילוי עצמי")
                {
                    DropDownList56.Visible = true;
                    Image3.Visible = true;
                    Image4.Visible = true;
                    TextBox53.Visible = true;
                   
                }

                else
                {
                    DropDownList56.Visible = false;
                    Image3.Visible = false;
                    Image4.Visible = false;
                    TextBox53.Visible = false;
                }

                ////////////////////////////////////////////////////
                if (DropDownList58.Text == "שדה למילוי עצמי")
                {
                    DropDownList58.Visible = true;
                    Image5.Visible = true;
                    Image6.Visible = true;
                    TextBox54.Visible = true;

                }

                else
                {
                    DropDownList58.Visible = false;
                    Image5.Visible = false;
                    Image6.Visible = false;
                    TextBox54.Visible = false;
                }

                ////////////////////////////////////////////////////

                if (DropDownList59.Text == "שדה למילוי עצמי")
                {
                    DropDownList59.Visible = true;
                    Image7.Visible = true;
                    Image8.Visible = true;
                    TextBox55.Visible = true;

                }

                else
                {
                    DropDownList59.Visible = false;
                    Image7.Visible = false;
                    Image8.Visible = false;
                    TextBox55.Visible = false;
                }

                ////////////////////////////////////////////////////

                if (DropDownList60.Text == "שדה למילוי עצמי")
                {
                    DropDownList60.Visible = true;
                    Image9.Visible = true;
                    TextBox56.Visible = true;
                   
                    

                }

                else
                {
                    DropDownList60.Visible = false;
                    Image9.Visible = false;
                    TextBox56.Visible = false;
                }

                ////////////////////////////////////////////////////



                if (Label72.Text == "1")
                {
                    CheckBox1.Checked = true;
                }

                else
                {
                    CheckBox1.Checked = false;
                }

                ////////////////////////////////////////////////////
                if (Label73.Text == "1")
                {
                    CheckBox2.Checked = true;
                }

                else
                {
                    CheckBox2.Checked = false;
                }

                ////////////////////////////////////////////////////
                if (Label74.Text == "1")
                {
                    CheckBox3.Checked = true;
                }

                else
                {
                    CheckBox3.Checked = false;
                }

                ////////////////////////////////////////////////////
                if (Label75.Text == "1")
                {
                    CheckBox4.Checked = true;
                }

                else
                {
                    CheckBox4.Checked = false;
                }

                ////////////////////////////////////////////////////


                if (Label76.Text == "1")
                {
                    CheckBox5.Checked = true;
                }

                else
                {
                    CheckBox5.Checked = false;
                }


                ////////////////////////////////////////////////////


                if (Label77.Text == "1")
                {
                    CheckBox6.Checked = true;
                }

                else
                {
                    CheckBox6.Checked = false;
                }

                ////////////////////////////////////////////////////


                if (Label78.Text == "1")
                {
                    CheckBox7.Checked = true;
                }

                else
                {
                    CheckBox7.Checked = false;
                }



                ////////////////////////////////////////////////////


                if (Label79.Text == "1")
                {
                    CheckBox8.Checked = true;
                }

                else
                {
                    CheckBox8.Checked = false;
                }


                ////////////////////////////////////////////////////


                if (Label80.Text == "1")
                {
                    CheckBox13.Checked = true;
                }

                else
                {
                    CheckBox13.Checked = false;
                }

////////////////////////////////////////////////////

                if (Label68.Text == "1")
                {
                    CheckBox9.Checked = true;
                }

                else
                {
                    CheckBox9.Checked = false;
                }
//////////////////////////////////////////////////////
                if (Label69.Text == "1")
                {
                    CheckBox10.Checked = true;
                }

                else
                {
                    CheckBox10.Checked = false;
                }
//////////////////////////////////////////////////////

                if (Label70.Text == "1")
                {
                    CheckBox11.Checked = true;
                }

                else
                {
                    CheckBox11.Checked = false;
                }

////////////////////////////////////////////////////////////
                if (Label71.Text == "1")
                {
                    CheckBox12.Checked = true;
                }

                else
                {
                    CheckBox12.Checked = false;
                }

////////////////////////////////////////////////////////////
                //CheckBox9.Checked = dr[103].ToString();
                //CheckBox10.Checked = dr[104].ToString();

                //CheckBox11.Checked = dr[105].ToString();
                //CheckBox12.Checked = dr[106].ToString();

                //CheckBox1.Checked = dr[107].ToString();
                //CheckBox2.Checked = dr[109].ToString();
                //CheckBox3.Checked = dr[110].ToString();
                //CheckBox4.Checked = dr[111].ToString();

                //CheckBox5.Checked = dr[112].ToString();
                //CheckBox6.Checked = dr[113].ToString();
                //CheckBox7.Checked = dr[114].ToString();


                //CheckBox8.Checked = dr[115].ToString();
                //CheckBox13.Checked = dr[116].ToString();
                TextBox24.Text = dr[117].ToString();

                TextBox12.Text = dr[118].ToString();
                DropDownList2.Text = dr[123].ToString();
                DropDownList31.Text = dr[4].ToString();
           //  DropDownList2.Items.FindByValue(dr[123].ToString()).Selected = true;



                ListImages();







            }

        }

    }
    private void ListImages()
    {
        string path1 = Server.MapPath("upload/" + Session["edit_id"] + "/" + "/Image");
        if (!Directory.Exists(path1))
        {

        }
        else
        {
            DirectoryInfo dir = new DirectoryInfo(Server.MapPath("upload/" + Session["edit_id"] + "/Image"));
            FileInfo[] file = dir.GetFiles();
            ArrayList list = new ArrayList();
            foreach (FileInfo info in file)
            {
                if (info.Extension == ".jpg" || info.Extension == ".jpeg" || info.Extension == ".gif" || info.Extension == ".png")
                {
                    list.Add(info);
                }


                FileRepeater.DataSource = list;
                FileRepeater.DataBind();
            }
        }
    }

    protected void Save_Click(object sender, System.EventArgs e)
    {
        SqlConnection conn = null;
        conn = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString);
        conn.Open();


        //SqlCommand cm1 = new SqlCommand("update properties_rent set frontend=@frontend where p_id='" + Session["p_id"].ToString() + "'", conn);
        //cm1.Parameters.AddWithValue("@frontend", DropDownList32.SelectedValue);
        //cm1.ExecuteNonQuery();



        SqlCommand cmd = new SqlCommand("update properties_rent set frontend=@frontend,c_type=@c_type,cust_ctype=@cust_ctype, agent_name=@agent_name,type=@type,fname=@fname, lname=@lname,email=@email,phone=@phone,street=@street,houseno=@houseno,nghr=@nghr,city=@city,country=@country,zip=@zip,cust_proptype=@cust_proptype,custom_proptype=@custom_proptype,prop_cond=@prop_cond,@cust_prop_cond=@cust_prop_cond,nghr1=@nghr1,f_city=@f_city,f_country=@f_country,f_zip=@f_zip,f_street=@f_street,h_no=@h_no,apartment_no=@apartment_no,room=@room,floor_no=@floor_no,total_floor=@total_floor,buil_cond=@buil_cond,cust_cond=@cust_cond,no_resi=@no_resi,to_floor_no=@to_floor_no,age_of_building=@age_of_building,no_of_residence=@no_of_residence,parking=@parking, custom_park=@custom_park, furniture=@furniture,custom_furniture=@custom_furniture,toilet=@toilet,custom_toilet=@custom_toilet,shower=@shower,kitchen=@kitchen,custom_kitchen=@custom_kitchen,ground=@ground,custom_ground=@custom_ground,roof=@roof,view_prop=@view_prop,custom_view=@custom_view,front_rear_view=@front_rear_view,custom_front_rear=@custom_front_rear,garden=@garden,custom_garden=@custom_garden,evacuation_date=@evacuation_date,custome_evacuation_date=@custome_evacuation_date,land=@land,custom_land=@custom_land,area=@area,custom_area=@custom_area,arnona=@arnona,p_basement=@p_basement,cust_basement=@cust_basement,p_strong=@p_strong,cust_strong=@cust_strong, p_ac=@p_ac, cust_ac=@cust_ac, p_balconies=@p_balconies, p_balcony_area=@p_balcony_area,p_balcony_size=@p_balcony_size,p_balconies1=@p_balconies1,p_balcony_area1=@p_balcony_area1,p_balcony_size1=@p_balcony_size1,balconies_num=@balconies_num, p_maintance=@p_maintance,p_building=@p_building,cust_building=@cust_building,p_boiler=@p_boiler,cust_boiler=@cust_boiler,animals=@animals,cust_animals=@cust_animals,roommates=@roommates,cust_roommates=@cust_roommates,entering_date=@entering_date,elevator=@elevator,cust_elevator=@cust_elevator,permises=@permises,prop_size=@prop_size,sign_size=@sign_size,p_tax=@p_tax,r_est=@r_est, a_hours=@a_hours, guarntee=@guarntee, cust_guarntee=@cust_guarntee,voucher=@voucher,cust_vouc=@cust_vouc,smoke=@smoke,cust_smoke=@cust_smoke,price=@price,price_type=@price_type, old_price=@old_price, old_price_type=@old_price_type,p_north=@p_north,p_south=@p_south,p_east=@p_east, p_west=@p_west, p_smart=@p_smart,p_alarm=@p_alarm,p_bars=@p_bars,p_handi=@p_handi, p_teather=@p_teather,p_gym=@p_gym,p_zacuji=@p_zacuji,p_pool=@p_pool,custom=@custom,custom_ch=@custom_ch,comments=@comments,status1=@status1,rent_status=@rent_status,adding_date=@adding_date,adding_by=@adding_by,price_dur=@price_dur, wcdrop1=@wcdrop1, wccust1=@wccust1, wcdrop2=@wcdrop2, wccust2=@wccust2, wcdrop3=@wcdrop3, wccust3=@wccust3, wcdrop4=@wcdrop4, wccust4=@wccust4, shwrdrop1=@shwrdrop1, shwrcust1=@shwrcust1, shwrdrop2=@shwrdrop2, shwrcust2=@shwrcust2, shwrdrop3=@shwrdrop3, shwrcust3=@shwrcust3, balcdrop1=@balcdrop1, balcsize1=@balcsize1, balcontext1=@balcontext1, balconcust1=@balconcust1, balcdrop2=@balcdrop2, balcsize2=@balcsize2, balcontext2=@balcontext2, balconcust2=@balconcust2, balcdrop3=@balcdrop3, balcsize3=@balcsize3, balcontext3=@balcontext3, balconcust3=@balconcust3, nghrnew=@nghrnew, countrynw=@countrynw, St=@St, city3=@city3, cat_home=@cat_home, countyr=@countyr, apart=@apart, bathrooms5=@bathrooms5, cus_bathrooms=@cus_bathrooms, balcon_cust3=@balcon_cust3, balcon_cust4=@balcon_cust4, add_date=@add_date where p_id='" + Session["edit_id"].ToString() + "'", conn);
        cmd.Parameters.AddWithValue("@frontend", DropDownList32.SelectedValue);
        cmd.Parameters.AddWithValue("@c_type", DropDownList1.SelectedValue);
        cmd.Parameters.AddWithValue("@cust_ctype", TextBox20.Text);
        cmd.Parameters.AddWithValue("@agent_name", DropDownList31.SelectedValue);
        cmd.Parameters.AddWithValue("@type", "To Rent");

        cmd.Parameters.AddWithValue("@fname", txtfname1.Text);

        cmd.Parameters.AddWithValue("@lname", txtlname1.Text);

        cmd.Parameters.AddWithValue("@email", TextBox22.Text);
        cmd.Parameters.AddWithValue("@phone", TextBox21.Text);

        cmd.Parameters.AddWithValue("@street", txthno.Text);
        cmd.Parameters.AddWithValue("@houseno", txtcity.Text);
        cmd.Parameters.AddWithValue("@nghr", TextBox3.Text);

        cmd.Parameters.AddWithValue("@city", txtssn.Text);

        cmd.Parameters.AddWithValue("@country", txtzip.Text);
        cmd.Parameters.AddWithValue("@zip", TextBox23.Text);


        cmd.Parameters.AddWithValue("@cust_proptype", DropDownList5.SelectedValue);
        cmd.Parameters.AddWithValue("@custom_proptype", TextBox4.Text);
        cmd.Parameters.AddWithValue("@prop_cond", DropDownList8.SelectedValue);
        cmd.Parameters.AddWithValue("@cust_prop_cond", TextBox5.Text);

        cmd.Parameters.AddWithValue("@nghr1", TextBox35.Text);


        cmd.Parameters.AddWithValue("@f_city", TextBox28.Text);


        cmd.Parameters.AddWithValue("@f_country", txtpfcountry.Text);
        cmd.Parameters.AddWithValue("@f_zip", TextBox29.Text);
        cmd.Parameters.AddWithValue("@f_street", TextBox50.Text);

        cmd.Parameters.AddWithValue("@h_no", TextBox13.Text);

        cmd.Parameters.AddWithValue("@apartment_no", TextBox14.Text);
        cmd.Parameters.AddWithValue("@room", txtRoom.Text);

        cmd.Parameters.AddWithValue("@floor_no", TextBox25.Text);
        cmd.Parameters.AddWithValue("@total_floor", TextBox26.Text);
        cmd.Parameters.AddWithValue("@buil_cond", DropDownList44.SelectedValue);
        cmd.Parameters.AddWithValue("@cust_cond", TextBox15.Text);

      //  cmd.Parameters.AddWithValue("@no_resi", TextBox27.Text);
       // cmd.Parameters.AddWithValue("@to_floor_no", TextBox26.Text);
        cmd.Parameters.AddWithValue("@age_of_building", TextBox51.Text);

        cmd.Parameters.AddWithValue("@no_of_residence", TextBox27.Text);



        cmd.Parameters.AddWithValue("@parking", ddlparking.SelectedValue);
        cmd.Parameters.AddWithValue("@custom_park", txtpark.Text);


        cmd.Parameters.AddWithValue("@furniture", DropDownList18.SelectedValue);
        cmd.Parameters.AddWithValue("@custom_furniture", txtfurniture.Text);
        cmd.Parameters.AddWithValue("@toilet", DropDownList19.SelectedValue);
        cmd.Parameters.AddWithValue("@wcdrop1", DropDownList56.SelectedValue);
        cmd.Parameters.AddWithValue("@wcdrop2", DropDownList58.SelectedValue);
        cmd.Parameters.AddWithValue("@wcdrop3", DropDownList59.SelectedValue);
        cmd.Parameters.AddWithValue("@wcdrop4", DropDownList60.SelectedValue);
        cmd.Parameters.AddWithValue("@custom_toilet", txttoilets.Text);
        cmd.Parameters.AddWithValue("@wccust1", TextBox53.Text);
        cmd.Parameters.AddWithValue("@wccust2", TextBox54.Text);
        cmd.Parameters.AddWithValue("@wccust3", TextBox55.Text);
        cmd.Parameters.AddWithValue("@wccust4", TextBox56.Text);
        cmd.Parameters.AddWithValue("@shwrdrop1", DropDownList57.Text);
        cmd.Parameters.AddWithValue("@shwrdrop2", DropDownList61.Text);
        cmd.Parameters.AddWithValue("@shwrdrop3", DropDownList62.Text);
        cmd.Parameters.AddWithValue("@bathrooms5", DropDownList63.Text);

        cmd.Parameters.AddWithValue("@shwrcust1", TextBox57.Text);
        cmd.Parameters.AddWithValue("@shwrcust2", TextBox58.Text);
        cmd.Parameters.AddWithValue("@shwrcust3", TextBox59.Text);

        cmd.Parameters.AddWithValue("@balcdrop1", txtBalconies1.SelectedValue);
        
        cmd.Parameters.AddWithValue("@cus_bathrooms", TextBox60.Text);
        cmd.Parameters.AddWithValue("@shower", DropDownList20.SelectedValue);
       // cmd.Parameters.AddWithValue("@custom_shower", TextBox16.Text);

        cmd.Parameters.AddWithValue("@kitchen", ddlkitchen.SelectedValue);
        cmd.Parameters.AddWithValue("@custom_kitchen", txtkitchen.Text);
        cmd.Parameters.AddWithValue("@ground", ddlground.SelectedValue);
        cmd.Parameters.AddWithValue("@custom_ground", txtground.Text);
        cmd.Parameters.AddWithValue("@roof", TextBox52.Text);

        cmd.Parameters.AddWithValue("@view_prop", DropDownList11.SelectedValue);

        cmd.Parameters.AddWithValue("@custom_view", TextBox8.Text);

        cmd.Parameters.AddWithValue("@nghrnew", txtcpsize.Text);


        cmd.Parameters.AddWithValue("@front_rear_view", DropDownList16.SelectedValue);
        cmd.Parameters.AddWithValue("@custom_front_rear", TextBox11.Text);
        cmd.Parameters.AddWithValue("@garden", ddlgarden.SelectedValue);

        cmd.Parameters.AddWithValue("@custom_garden", txtgarden.Text);
        cmd.Parameters.AddWithValue("@evacuation_date", DropDownList12.SelectedValue);
        cmd.Parameters.AddWithValue("@custome_evacuation_date", TextBox7.Text);
        cmd.Parameters.AddWithValue("@balcon_cust4", TextBox69.Text);
        



        cmd.Parameters.AddWithValue("@land", DropDownList15.SelectedValue);
        cmd.Parameters.AddWithValue("@custom_land", TextBox10.Text);
        cmd.Parameters.AddWithValue("@area", DropDownList25.SelectedValue);
        cmd.Parameters.AddWithValue("@custom_area", TextBox17.Text);
        cmd.Parameters.AddWithValue("@arnona", TextBox40.Text);

        cmd.Parameters.AddWithValue("@p_basement", txtBasement.Text);
        cmd.Parameters.AddWithValue("@cust_basement", txtbasetxt.Text);

        cmd.Parameters.AddWithValue("@p_strong", txtStrong.Text);

        cmd.Parameters.AddWithValue("@cust_strong", txtstrongtxt.Text);
        cmd.Parameters.AddWithValue("@p_ac", txtAC.Text);

        cmd.Parameters.AddWithValue("@cust_ac", txtactxt.Text);

        cmd.Parameters.AddWithValue("@p_balconies", txtBalconies.Text);
        cmd.Parameters.AddWithValue("@p_balcony_area", TextBox6.Text);
        cmd.Parameters.AddWithValue("@p_balcony_size", DropDownList41.SelectedValue);
        cmd.Parameters.AddWithValue("@p_balconies1", txtBalconies0.Text);
        cmd.Parameters.AddWithValue("@p_balcony_area1", TextBox38.Text);
        cmd.Parameters.AddWithValue("@p_balcony_size1", DropDownList42.SelectedValue);

      //  cmd.Parameters.AddWithValue("@balconies_num", DropDownList42.SelectedValue);

        cmd.Parameters.AddWithValue("@p_maintance", TextBox9.Text);
        cmd.Parameters.AddWithValue("@p_building", ddlbuiding.SelectedValue);
        cmd.Parameters.AddWithValue("@cust_building", txtbuilding.Text);
        cmd.Parameters.AddWithValue("@p_boiler", ddlboiler.SelectedValue);
        cmd.Parameters.AddWithValue("@cust_boiler", txtboiler.Text);
        cmd.Parameters.AddWithValue("@animals", ddlanimals.SelectedValue);
        cmd.Parameters.AddWithValue("@cust_animals", txtanimals.Text);
        cmd.Parameters.AddWithValue("@roommates", ddlroommates.Text);
     //   cmd.Parameters.AddWithValue("@cust_smoke", txtroomates.Text);
        cmd.Parameters.AddWithValue("@entering_date", TextBox37.Text);
        cmd.Parameters.AddWithValue("@elevator", DropDownList50.SelectedValue);
        cmd.Parameters.AddWithValue("@cust_elevator", TextBox19.Text);
        cmd.Parameters.AddWithValue("@permises", txtProperty.Text);

        cmd.Parameters.AddWithValue("@prop_size", txtpsize.Text);
        cmd.Parameters.AddWithValue("@sign_size", ddlpsize.SelectedValue);
        cmd.Parameters.AddWithValue("@p_tax", TextBox31.Text);
        cmd.Parameters.AddWithValue("@balcon_cust3", TextBox68.Text);

        cmd.Parameters.AddWithValue("@r_est", TextBox32.Text);
        cmd.Parameters.AddWithValue("@a_hours", TextBox33.Text);
        cmd.Parameters.AddWithValue("@guarntee", ddlgrnte.SelectedValue);
        cmd.Parameters.AddWithValue("@cust_guarntee", txtgrnte.Text);
        cmd.Parameters.AddWithValue("@voucher", ddlvou.Text);

        cmd.Parameters.AddWithValue("@cust_vouc", txtvou.Text);


        cmd.Parameters.AddWithValue("@smoke", ddlsmoke.SelectedValue);
        cmd.Parameters.AddWithValue("@cust_roommates", txtsmoke.Text);


        cmd.Parameters.AddWithValue("@price", txtPrice.Text);
        cmd.Parameters.AddWithValue("@price_type", DropDownList33.SelectedValue);

        cmd.Parameters.AddWithValue("@old_price", txtOldPrice.Text);
        cmd.Parameters.AddWithValue("@old_price_type", DropDownList51.SelectedValue);




        cmd.Parameters.AddWithValue("@p_north", CheckBox9.Checked);
        cmd.Parameters.AddWithValue("@p_south", CheckBox10.Checked);

        cmd.Parameters.AddWithValue("@p_east", CheckBox11.Checked);
        cmd.Parameters.AddWithValue("@p_west", CheckBox12.Checked);

        cmd.Parameters.AddWithValue("@p_smart", CheckBox1.Checked);
        cmd.Parameters.AddWithValue("@p_alarm", CheckBox2.Checked);
        cmd.Parameters.AddWithValue("@p_bars", CheckBox3.Checked);
        cmd.Parameters.AddWithValue("@p_handi", CheckBox4.Checked);

        cmd.Parameters.AddWithValue("@p_teather", CheckBox5.Checked);
        cmd.Parameters.AddWithValue("@p_gym", CheckBox6.Checked);
        cmd.Parameters.AddWithValue("@p_zacuji", CheckBox7.Checked);


        cmd.Parameters.AddWithValue("@p_pool", CheckBox8.Checked);
        cmd.Parameters.AddWithValue("@custom", CheckBox13.Checked);
        cmd.Parameters.AddWithValue("@custom_ch", TextBox24.Text);

        cmd.Parameters.AddWithValue("@comments", TextBox12.Text);

        cmd.Parameters.AddWithValue("@cust_smoke", TextBox65.Text);
        cmd.Parameters.AddWithValue("@city3", txtColor.Text);

        cmd.Parameters.AddWithValue("@status1", "1");
        cmd.Parameters.AddWithValue("@rent_status", "1");
        cmd.Parameters.AddWithValue("@adding_date", System.DateTime.Now);
        cmd.Parameters.AddWithValue("@adding_by", "admin");
        cmd.Parameters.AddWithValue("@price_dur", DropDownList2.SelectedValue);
        cmd.Parameters.AddWithValue("@countyr", TextBox61.Text);

        cmd.Parameters.AddWithValue("@balcontext1", DropDownList64.Text);
        cmd.Parameters.AddWithValue("@balconcust1", TextBox66.Text);
        cmd.Parameters.AddWithValue("@balcdrop2", txtBalconies2.Text);
        cmd.Parameters.AddWithValue("@balcsize2", TextBox62.Text);
        cmd.Parameters.AddWithValue("@balcontext2", DropDownList65.Text);
        cmd.Parameters.AddWithValue("@balconcust2", TextBox67.Text);
        cmd.Parameters.AddWithValue("@balcdrop3", txtBalconies3.Text);
        cmd.Parameters.AddWithValue("@balcsize3", TextBox63.Text);
        cmd.Parameters.AddWithValue("@balcontext3", DropDownList66.Text);
        cmd.Parameters.AddWithValue("@balconcust3", TextBox70.Text);
        cmd.Parameters.AddWithValue("@countrynw", TextBox39.Text);
        ////////Blank////////////
        cmd.Parameters.AddWithValue("@no_resi", TextBox80.Text);
        cmd.Parameters.AddWithValue("@to_floor_no", TextBox81.Text);
        cmd.Parameters.AddWithValue("@balconies_num", TextBox82.Text);
        cmd.Parameters.AddWithValue("@balcsize1", TextBox83.Text);
        cmd.Parameters.AddWithValue("@St", TextBox84.Text);
        cmd.Parameters.AddWithValue("@cat_home", TextBox85.Text);
        cmd.Parameters.AddWithValue("@apart", TextBox86.Text);
        cmd.Parameters.AddWithValue("@add_date", TextBox87.Text);


        cmd.ExecuteNonQuery();
        fileupload1();
        //SqlCommand cm1 = new SqlCommand("update properties_rent set frontend ='"+ DropDownList32.SelectedItem.Value+ " ' ,c_type ='" + DropDownList1.SelectedValue + " ' , cust_ctype ='" + TextBox20.Text + " ' ,agent_name  ='" + DropDownList31.SelectedValue + " ' ,type ='" + "To Rent" + " ' ,fname ='" + txtfname1.Text + " ' ,lname ='" + txtlname1.Text + " ' , email ='" + TextBox22.Text + " ' ,phone ='" + TextBox21.Text + " ' ,street ='" + txthno.Text + " ' ,houseno ='" + txtcity.Text + " ' ,nghr ='" + TextBox3.Text + " ' , city ='" + txtssn.Text + " ' ,country ='" + txtzip.Text + " ' , zip ='" + TextBox23.Text + " ' , cust_proptype ='" + DropDownList5.SelectedValue + " ' ,  custom_proptype ='" + TextBox4.Text + " ' , prop_cond ='" + DropDownList8.SelectedValue + " ' ,cust_prop_cond ='" + TextBox5.Text + " ' ,nghr1 ='" + TextBox35.Text + " ' , f_city ='" + TextBox28.Text + " ' ,f_country ='" + txtpfcountry.Text + " ' , f_zip ='" + TextBox29.Text + " ' , f_street ='" + TextBox50.Text + " ' ,h_no ='" + TextBox13.Text + " ' ,apartment_no ='" + TextBox14.Text + " ' ,room ='" + txtRoom.Text + " ' , floor_no ='" + TextBox25.Text + " ' ,total_floor ='" + TextBox26.Text + " ' , buil_cond ='" + DropDownList44.SelectedValue + " ' ,cust_cond ='" + TextBox15.Text + " ' , no_resi ='" + TextBox27.Text + " ' , to_floor_no ='" + TextBox26.Text + " ' , age_of_building ='" + TextBox51.Text + " ' ,no_of_residence ='" + TextBox27.Text + " ' ,parking ='" + ddlparking.SelectedValue + " ' , custom_park ='" + txtpark.Text + " ' ,furniture ='" + DropDownList18.SelectedValue + " ' ,custom_furniture ='" + txtfurniture.Text + " ' , toilet ='" + DropDownList19.SelectedValue + " ' , custom_toilet ='" + txttoilets.Text + " ' ,shower ='" + DropDownList20.SelectedValue + " ' , custom_shower ='" + TextBox64.Text + " ' , kitchen ='" + ddlkitchen.SelectedValue + " ' ,custom_kitchen ='" + txtkitchen.Text + " ' ,ground ='" + ddlground.SelectedValue + " ' ,custom_ground ='" + txtground.Text + " ' ,roof ='" + TextBox52.Text + " ' , view_prop ='" + DropDownList11.SelectedValue + " ' ,custom_view ='" + TextBox8.Text + " ' ,front_rear_view ='" + DropDownList16.SelectedValue + " ' ,custom_front_rear ='" + TextBox11.Text + " ' ,garden ='" + ddlgarden.SelectedValue + " ' ,custom_garden ='" + txtgarden.Text + " ' ,evacuation_date ='" + DropDownList12.SelectedValue + " ' ,custome_evacuation_date ='" + TextBox7.Text + " ' ,land ='" + DropDownList15.SelectedValue + " ' ,custom_land ='" + TextBox10.Text + " ' , area ='" + DropDownList25.SelectedValue + " ' , custom_area ='" + TextBox17.Text + " ' , arnona ='" + TextBox40.Text + " ' ,p_basement ='" + txtBasement.Text + " ' ,cust_basement ='" + txtbasetxt.Text + " ' , p_strong ='" + txtStrong.Text + " ' , cust_strong ='" + txtstrongtxt.Text + " ' , p_ac ='" + txtAC.Text + " ' ,cust_ac ='" + txtactxt.Text + " ' ,p_balconies ='" + txtBalconies.Text + " ' ,p_balcony_area ='" + TextBox6.Text + " ' ,p_balcony_size ='" + DropDownList41.SelectedValue + " ' , p_balconies1 ='" + txtBalconies0.Text + " ' ,p_balcony_area1 ='" + TextBox38.Text + " ' , p_balcony_size1 ='" + DropDownList42.SelectedValue + " ' ,  balconies_num ='" + DropDownList42.SelectedValue + " ' ,p_maintance ='" + TextBox9.Text + " ' ,p_building ='" + ddlbuiding.SelectedValue + " ' ,cust_building ='" + txtbuilding.Text + " ' ,p_boiler ='" + ddlboiler.SelectedValue + " ' ,cust_boiler ='" + txtboiler.Text + " ' ,animals ='" + ddlanimals.SelectedValue + " ' ,cust_animals ='" + txtanimals.Text + " ' ,roommates ='" + ddlroommates.SelectedValue + " ' ,cust_roommates ='" + txtroomates.Text + " ' ,entering_date ='" + TextBox37.Text + " ' , elevator ='" + DropDownList50.SelectedValue + " ' , cust_elevator ='" + TextBox19.Text + " ' ,permises ='" + txtProperty.Text + " ' ,  prop_size ='" + txtpsize.Text + " ' ,sign_size ='" + ddlpsize.SelectedValue + " ' , p_tax ='" + TextBox31.Text + " ' ,r_est ='" + TextBox32.Text + " ' ,a_hours ='" + TextBox33.Text + " ' ,guarntee ='" + ddlgrnte.SelectedValue + " ' ,cust_guarntee ='" + txtgrnte.Text + " ' , voucher ='" + ddlvou.Text + " ' ,cust_vouc ='" + txtvou.Text + " ' , smoke ='" + ddlsmoke.SelectedValue + " ' , cust_smoke ='" + txtsmoke.Text + " ' , price ='" + txtPrice.Text + " ' ,price_type ='" + DropDownList33.SelectedValue + " ' ,old_price ='" + txtOldPrice.Text + " ' , old_price_type ='" + DropDownList51.SelectedValue + " ' ,p_north ='" + CheckBox9.Checked + " ' , p_south ='" + CheckBox10.Checked + " ' ,p_east ='" + CheckBox11.Checked + " ' , p_west ='" + CheckBox12.Checked + " ' , p_smart ='" + CheckBox1.Checked + " ' ,p_alarm ='" + CheckBox2.Checked + " ' ,p_bars ='" + CheckBox3.Checked + " ' , p_handi ='" + CheckBox4.Checked + " ' , p_teather ='" + CheckBox5.Checked + " ' , p_gym ='" + CheckBox6.Checked + " ' ,p_zacuji ='" + CheckBox7.Checked + " ' , p_pool ='" + CheckBox8.Checked + " ' ,custom ='" + CheckBox13.Checked + " ' , custom_ch ='" + TextBox24.Text + " ' , comments ='" + TextBox12.Text + " ' , status1 ='" + "0" + " ' ,rent_status ='" + "0" + " ' ,adding_date ='" + System.DateTime.Now + " ' , price_dur ='" + DropDownList2.SelectedValue + " ' where p_id='" + Session["p_id"].ToString () + "'", conn);
        //cm1.ExecuteNonQuery();

        Response.Redirect("adminUpdatePropConf.aspx");

    }

    public void fileupload1()
    {

        if (FileUpload1.HasFile)
        {
            string path = Server.MapPath("upload/" + Session["edit_id"] + "/" + "Image");
            if (!Directory.Exists(path))
            {
                Directory.CreateDirectory(path);


                if (FileUpload1.HasFile)
                {

                    HttpFileCollection hfc = Request.Files;
                    for (int i = 0; i < hfc.Count; i++)
                    {

                        HttpPostedFile hpf = hfc[i];
                        if (hpf.ContentLength > 0)
                        {

                            hpf.SaveAs(Server.MapPath("upload/" + Session["edit_id"] + "/" + "Image/" + System.IO.Path.GetFileName(hpf.FileName)));


                            SqlConnection co = null;
                            co = new SqlConnection(ConfigurationManager.ConnectionStrings["ConnStr"].ConnectionString);
                            co.Open();

                            SqlCommand cmd1 = new SqlCommand("Insert into images_torent values(@id,@FileName ,@FilePath,@f_end)", co);
                            //id nvarchar (50),
                            //FileName nvarchar (50),
                            //FilePath nvarchar (50)


                            cmd1.Parameters.AddWithValue("@id", Session["edit_id"]);
                            cmd1.Parameters.AddWithValue("@FileName", System.IO.Path.GetFileName(hpf.FileName));
                            cmd1.Parameters.AddWithValue("@FilePath", ("upload/" + Session["edit_id"] + "/Image/" + hpf.FileName));
                            cmd1.Parameters.AddWithValue("@f_end", DropDownList32.SelectedValue);

                            cmd1.ExecuteNonQuery();
                            co.Close();
                        }
                    }
                }
            }
        }
    }
    protected void ok(object sender, System.EventArgs e)
    {
    }
    protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e)
    {
        if (e.CommandName == "action")
        {

            //Label1.Text = "hello";
            int index = Convert.ToSByte(e.CommandArgument);

            GridViewRow row = GridView2.Rows[index];
            SqlDataAdapter adp = new SqlDataAdapter();
            SqlCommand cmd1 = new SqlCommand();
            DataSet ds = new DataSet();


            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["Connstr"].ConnectionString);

            con.Open();

            SqlCommand objectvalue = new SqlCommand("", con);
            cmd1.Connection = con;

            SqlCommand dmc = new SqlCommand("Delete from properties_rent where p_id='" + row.Cells[0].Text + "'", con);
            dmc.ExecuteNonQuery();

            // SqlCommand dmc = new SqlCommand("select p_id from properties where p_id='" + row.Cells[0].Text + "'", con);

            //dmc.ExecuteNonQuery();
            //  Session["p_id"] = row.Cells[0].Text;

            con.Close();
            // Response.Write(Session["p_id"]);
            // Response.Write(@"<script language='javascript'>alert('clent has been selected')</script>");

            Response.Redirect("report_property_for_rent.aspx");
            // con.Close();


        }



        if (e.CommandName == "view")
        {

            //Label1.Text = "hello";
            int index = Convert.ToSByte(e.CommandArgument);

            GridViewRow row = GridView2.Rows[index];
            SqlDataAdapter adp = new SqlDataAdapter();
            SqlCommand cmd1 = new SqlCommand();
            DataSet ds = new DataSet();


            SqlConnection con = new SqlConnection(ConfigurationManager.ConnectionStrings["Connstr"].ConnectionString);

            con.Open();

            SqlCommand objectvalue = new SqlCommand("", con);
            cmd1.Connection = con;



            SqlCommand dmc = new SqlCommand("select t_id from task where t_id='" + row.Cells[0].ToString() + "'", con);

            dmc.ExecuteNonQuery();
            Session["t_id"] = row.Cells[0].Text.ToString();

            con.Close();
            // Response.Write(Session["p_id"]);
            // Response.Write(@"<script language='javascript'>alert('clent has been selected')</script>");

            Response.Redirect("edit-task.aspx");
            // con.Close();


        }

    }

    protected void txtBalconies0_SelectedIndexChanged(object sender, EventArgs e)
    {

    }
    protected void DropDownList56_SelectedIndexChanged(object sender, EventArgs e)
    {
     

    }
    protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
    {
       
            DropDownList56.Visible = true;
            Image3.Visible = true;
            Image4.Visible = true;
            TextBox53.Visible = true;
       
    }
    protected void txtBalconies_SelectedIndexChanged(object sender, EventArgs e)
    {
        if (txtBalconies.Text == "שדה למילוי עצמי")
        {
            TextBox66.Visible = true;


        }

        else
        {
            TextBox66.Visible = false;

        }

    }



}